****** Appendix: Figure A4
****** Average leader transfer by round for each treatment group
ssc install schemepack, replace
clear all
version 17.0
cd 
import delimited "data\cleaned\uganda_jun17_cleaned.csv", bindquote(strict) varnames(1) clear

gen treat = treatment_pooled
* Removing practice round and subsetting just to those treatments & roles of interest
keep if role == "C" & round != 1 & inlist(treat, "Strong Hidden VAT", "Weak Hidden VAT", "Direct Tax", "Windfall") & !inlist(leader_id, "c", "s")
replace treat = "Hidden VAT" if treatment == "Strong Hidden VAT"
replace treat = "Visible VAT" if treatment == "Weak Hidden VAT"


* Mean transfer by treatment-round
keep date_exp leader_transfer session_exp round leader_id treat enum_id
rename treat treatment
destring leader_transfer, replace

collapse (mean) leader_transfer, by(date_exp session_exp round treatment enum_id)
replace treatment = subinstr(treatment, " ", "_", .)
greshape wide leader_transfer, i(round session_exp date_exp enum_id) j(treatment) string

la var leader_transferDirect_Tax "Direct Tax"
la var leader_transferHidden_VAT "Hidden VAT"
la var leader_transferVisible_VAT "Visible VAT"
la var leader_transferWindfall "Windfall"

sort date_exp session_exp round enum_id

renvars leader_*, predrop(15)

foreach var of varlist Direct_Tax Hidden_VAT Visible_VAT Windfall{
	egen mean_`var' = mean(`var'), by(round)
}

la var mean_Direct_Tax "Direct Tax"
la var mean_Hidden_VAT "Hidden VAT"
la var mean_Visible_VAT "Visible VAT"
la var mean_Windfall "Windfall"
la var round "Round"

sort round

set scheme gg_hue

graph set window fontface "Arial Narrow"
twoway (line mean_Direct_Tax round, lcolor(gs0) lpattern(longdash)) (line mean_Hidden_VAT round, lcolor(gs4) lpattern(dash)) (line mean_Visible_VAT round, lcolor(gs8) lpattern(shortdash)) (line mean_Windfall round, lcolor(gs12) lpattern(solid)), ylabel(0(2)10)  

gr export "figures/appendix/appendix_fig_a4.pdf"